package com.ebo.commonlib.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * Created by admin on 2018/6/10.
 */

public class DigitUtils {
    public static String doublestr(double value,int digits){
        DecimalFormat formater = new DecimalFormat();
        formater.setMaximumFractionDigits(digits);
        formater.setGroupingSize(0);
        formater.setRoundingMode(RoundingMode.FLOOR);
        String result = formater.format(value);
        return result;


    }

    //科学计数法转普通计数法
    public static String getOrdinaryCounting(String str) {
        BigDecimal db = new BigDecimal(str);
        str = db.toPlainString();
        return str;
    }

    public static String getOrdinaryCounting(double value) {
        BigDecimal db = new BigDecimal(value);
        String str = db.toPlainString();
        return str;
    }

}
